<template>
  <div class="box">
    <div id="wxcode"></div>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {};
  },
  mounted() {
    this.createSrc();
    setTimeout(() => {
      this.init();
    }, 1000);
  },
  watch: {
    $route(newv, oldv) {
      console.log({ newv });
      console.log({ oldv });
    },
  },
  methods: {
    createSrc() {
      const oScript = document.createElement("script");
      oScript.type = "text/javascript";
      oScript.src = "http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js";
      document.body.appendChild(oScript);
      console.log({ oScript });
    },
    init() {
      var param = {
        self_redirect: false,
        id: "wxcode",
        appid: "wx30894a89a4d7635c",
        scope: "snsapi_login",
        redirect_uri: "http://www.huanchenxinnengyuan.com",
        state: "STATE#wechat_redirect",
        style: "black",
        href: "",
      };
      var obj = new WxLogin(param);
      console.log({ obj });
    },
  },
};
</script>
<style scoped>
.box {
  border: 1px solid red;
}
</style>
